package com.jianbing.util.gjj;

import com.alibaba.fastjson.JSON;
import com.jianbing.dao.MongoDBDao;
import com.jianbing.entity.GjjCity;
import com.jianbing.entity.datacheck.ColumnCheck;
import com.jianbing.entity.datacheck.ColumnCheckInfo;
import com.jianbing.entity.datacheck.DataCheckRule;
import com.jianbing.entity.gjjdata.GjjData;
import com.jianbing.entity.gjjdata.GjjDataDetail;
import com.jianbing.exception.ServiceException;
import com.jianbing.util.*;
import com.jianbing.util.datacheck.DataCheckHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Pattern;

/**
 * Created by hantixiang on 2016/12/13.
 */
public class GjjDataHelper {
	private static final Log log = LogFactory.getLog(GjjDataHelper.class);
	private static Pattern integerPatten = Pattern.compile("^[-\\+]?[\\d]*$");
	private static Pattern floatPatten = Pattern.compile("^[-\\+]?[\\d]+[\\.]{1}[\\d]*$");
	private static Date beforeDate = DateUtils.get("1900-01-01");
	private static Pattern specialPatten = Pattern.compile("^(\\w*[!@#$~^&*`]+\\w*)+$");
	private static Pattern idCardPatten = Pattern.compile("^(\\d{15}$|^\\d{18}$|^\\d{17}(\\d|X|x))$");
	private static Pattern yyyyMMPatten = Pattern.compile("^\\d{4}-\\d{2}$");
	private static Pattern emailPatten = Pattern.compile("^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9]+)+$");

	/*
	 * public static final String ID = "ID"; public static final String
	 * customer_id = "customer_id"; public static final String state = "state";
	 * public static final String name = "name"; public static final String
	 * company = "company"; public static final String balance = "balance";
	 * public static final String deposite_base = "deposite_base"; public static
	 * final String base = "base"; public static final String person_rate =
	 * "person_rate"; public static final String company_rate = "company_rate";
	 * public static final String initial_date = "initial_date"; public static
	 * final String deposite_base_guess = "deposite_base_guess"; public static
	 * final String record_date = "record_date";
	 */
	public static void main(String[] args) {
		String data = "{\n" + "\n" + "    \"ID\": \"331081199108179411\",\n" + "\n"
				+ "    \"customer_id\": \"0120205000280\",\n" + "\n" + "    \"name\": \"Ye5E4p1EVHTmj94KTUKnEw\",\n"
				+ "\n" + "    \"state\": \"正常\",\n" + "\n" + "    \"company\": \"广元市工商行政管理局\",\n" + "\n"
				+ "    \"base\": \"164.00\",\n" + "\n" + "    \"balance\": \"99296.64\",\n" + "\n"
				+ "    \"deposite_base\": \"820.00\",\n" + "\n" + "    \"person_rate\": \"10.00\",\n" + "\n"
				+ "    \"company_rate\": \"10.00\",\n" + "\n" + "    \"record_date\": \"2016-11-17\",\n" + "\n"
				+ "    \"details\": [\n" + "\n" + "      {\n" + "\n" + "        \"company\":\"\",\n" + "\n"
				+ "        \"serialNum\":\"\",\n" + "\n" + "        \"tradeDate\":\"2016-11-17\",\n" + "\n"
				+ "        \"tradeType\":\"补缴201611\",\n" + "\n" + "        \"tradeYearMouth\":\"\",\n" + "\n"
				+ "        \"tradeMoney\":\"1100.00\",\n" + "\n" + "        \"balance\":\"99296.64\"\n" + "\n"
				+ "      }\n" + "\t  \n" + "\t  ]\n" + "  }\n";

		GjjData gjjData = JSON.parseObject(data, GjjData.class);

		Map map = checkGjjData(data, 3);

		System.out.println(JSON.toJSONString(map));
//		System.out.println(map);

		/*
		 * String ss = "！"; System.out.println(containChinese(ss));
		 * 
		 * String num = "-620121198511105330"; Pattern patten =
		 * Pattern.compile("^\\d{18}$");
		 * System.out.println(isNegativeNumber(num));
		 * 
		 * String date = "1989-11"; System.out.println(yyyyMMDateCheck(date));
		 * String email = "aaazhonga111.com.cn";
		 */

		// TODO
		// 从左至右的检查逻辑运算，记录位置
		// System.out.println(isEmail(email));
	}

	public static Map checkGjjData(String data, Integer cityId) {
		Map checkResult = new HashMap();
		try {
			Map queryParams = new HashMap<>();
			queryParams.put("cityId", cityId);
			ColumnCheckInfo columnCheckInfo = MongoDBDao.findOne(TableUtils.getTableName(ColumnCheckInfo.class), queryParams,
					ColumnCheckInfo.class);
			if (columnCheckInfo == null) {
				return null;
			}
			GjjData gjjData = JSON.parseObject(data, GjjData.class);
			List<GjjDataDetail> detailDateList = gjjData.getDetails();
			if (StringUtils.isNotEmpty(columnCheckInfo.getBrief())) {
				List<ColumnCheck> columnChecks = JSON.parseArray(columnCheckInfo.getBrief(), ColumnCheck.class);
				Map briefCheckResult = checkColumn(columnChecks, gjjData,GjjData.class);
				checkResult.put("brief", briefCheckResult);
			}
			if (StringUtils.isNotEmpty(columnCheckInfo.getDetail())) {
				List<Map> detailCheckResultList = new ArrayList<Map>();
				List<ColumnCheck> detailColumnCheck = JSON.parseArray(columnCheckInfo.getDetail(), ColumnCheck.class);
				if(ColletionUtils.isNotEmpty(detailDateList)){
					for(GjjDataDetail gjjDataDetail : detailDateList){
						Map detailCheckResult = checkColumn(detailColumnCheck, gjjDataDetail,GjjDataDetail.class);
						detailCheckResultList.add(detailCheckResult);
					}
				}
				
				checkResult.put("detail", detailCheckResultList);
			}
		} catch (ServiceException e) {
			log.error(e.toString(), e);
			return null;
		}
		return checkResult;
	}

	public static <T> Map checkColumn(List<ColumnCheck> columnChecks, Object gjjData,Class<T> classType) throws ServiceException {
		DataCheckRule rule = null;
		int ruleIdInt = -1;
		String dataCheckRuleTable = TableUtils.getTableName(DataCheckRule.class);
		Map checkResult = new HashMap();
		for (ColumnCheck column : columnChecks) {
//			List<Map> list = new ArrayList<>();
			Map map = new HashMap();
			String currentColumnName = column.getColumn();
			String ids = column.getRuleIds();
			String[] ruleIdsArray = ids.split(",");
			for (String ruleId : ruleIdsArray) {
				ruleIdInt = Integer.parseInt(ruleId);
				rule = MongoDBDao.findOne(dataCheckRuleTable, ruleIdInt, DataCheckRule.class);
				if (rule == null) {
					continue;
				}
				String ruleExpression = rule.getExpr();
				if (StringUtils.isNotEmpty(ruleExpression)) {
					String[] ruleExpressionArray = ruleExpression.split(",");
					for (String ruleExp : ruleExpressionArray) {
						check(map, ruleExp, currentColumnName, gjjData,classType);
					}
				}
//				list.add(map);
			}
			checkResult.put(column.getColumn(), map);
		}
		return checkResult;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	private static <T> boolean check(Map map, String ruleExp, String currentColumnName, Object gjjData,Class<T> classType) {
		if (StringUtils.isEmpty(ruleExp) || StringUtils.isEmpty(currentColumnName) || gjjData == null) {
			return false;
		}
		boolean checkResult = false;
		Map<String,String> dataCheckRuleMap = DataCheckHelper.getNewDataCheckRule();
		if (ruleExp.startsWith(DataCheckHelper.containAsterisk)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = containAsterisk(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.containAsterisk),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.containSpecialChar)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = containSpecialChar(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.containSpecialChar),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.containChinese)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = containChinese(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.containChinese),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.containSpace)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = containSpace(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.containChinese),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.contains(DataCheckHelper.len)) {
			String value = getValue(currentColumnName, gjjData,classType);
			int len = len(value);
			ruleExp = ruleExp.replaceAll("len", len + "");
			checkResult = (Boolean) OperatorEngine.eval(ruleExp);
		} else if (ruleExp.startsWith(DataCheckHelper.letter)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isLetter(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.letter), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.numberOrLetter)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = numberOrLetter(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.numberOrLetter),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.notChinese)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = !chinese(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.notChinese), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.chinese)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = chinese(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.chinese), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.IDCardNumber)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isIdCard(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.IDCardNumber),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.date)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isDate(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.date), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.dateAfter1900year)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isAfter1900Year(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.dateAfter1900year),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.dateBeforeNow)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isBefereNow(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.dateBeforeNow),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.yyyyMMDate)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = yyyyMMDateCheck(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.yyyyMMDate), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.isNumber)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isNumber(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.isNumber), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.positiveNumber)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isPositiveNumber(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.positiveNumber),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.negativeNumber)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isNegativeNumber(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.negativeNumber),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.decimal)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isDecimal(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.decimal), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.integer)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isInteger(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.integer), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.baseEqualPerPayPlusComPay)) {
			checkResult = baseEqualPerPayPlusComPay(gjjData);
			map.put(dataCheckRuleMap.get(DataCheckHelper.baseEqualPerPayPlusComPay),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.baseLessDepositeBase)) {
			checkResult = baseLessDepositeBase(gjjData);
			map.put(dataCheckRuleMap.get(DataCheckHelper.baseLessDepositeBase),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.balanceEqualsDetailBalanceSum)) {
			checkResult = balanceEqualsDetailBalanceSum(gjjData);
			map.put(dataCheckRuleMap.get(DataCheckHelper.balanceEqualsDetailBalanceSum),
					checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		} else if (ruleExp.startsWith(DataCheckHelper.email)) {
			String value = getValue(currentColumnName, gjjData,classType);
			checkResult = isEmail(value);
			map.put(dataCheckRuleMap.get(DataCheckHelper.email), checkResult ? DataCheckHelper.CHECK_PASS : DataCheckHelper.CHECK_FAIL);
		}
		return checkResult;
	}

	private static <T> String getValue(String columnName, Object obj,Class<T> classType) {
		String methodName = "get" + columnName.substring(0, 1).toUpperCase() + columnName.substring(1);
		Method[] methods = classType.getDeclaredMethods();
		Method callMethod = null;
		for (Method method : methods) {
			if (method.getName().equals(methodName)) {
				callMethod = method;
				break;
			}
		}
		Object result = null;
		try {
			result = callMethod.invoke(obj, null);
			if (result != null) {
				return result.toString();
			}
		} catch (Exception e) {
			log.error(e.toString(), e);
		}
		return "";
	}

	public static boolean yyyyMMDateCheck(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		}

		if (!yyyyMMPatten.matcher(value).matches()) {
			return false;
		}

		Date date = DateUtils.yyyyMMDate(value);
		if (date == null)
			return false;
		return true;
	}

	public static boolean isIdCard(String value) {
		return idCardPatten.matcher(value).matches();
	}

	/**
	 * 是否含有*
	 *
	 * @param value
	 * @return
	 */
	public static boolean containAsterisk(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		} else {
			return value.contains("*");
		}
	}

	/**
	 * 是否含有特殊字符
	 *
	 * @param value
	 * @return
	 */
	public static boolean containSpecialChar(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		} else {
			return specialPatten.matcher(value).matches();
		}
	}

	/**
	 * 月交基数是否等于基数和比率计算结果校验
	 * @param <T>
	 *
	 * @param gjjData
	 * @return
	 */
	public static <T> boolean baseEqualPerPayPlusComPay(Object obj) {
		if (obj == null) {
			return false;
		}
		GjjData gjjData = new GjjData();
		if(obj instanceof GjjData){
			gjjData = (GjjData)obj;
		}else{
			return false;
		}
		try {
			BigDecimal base = new BigDecimal(gjjData.getBase());
			BigDecimal companyRate = new BigDecimal(gjjData.getCompany_rate());
			BigDecimal personRate = new BigDecimal(gjjData.getPerson_rate());
			BigDecimal deposite_base = new BigDecimal(gjjData.getDeposite_base());
			BigDecimal calcBase = deposite_base.multiply(companyRate).add(deposite_base.multiply(personRate));
			return calcBase.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() == base
					.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
		} catch (Exception e) {
			log.error(e.toString(), e);
			return false;
		}
	}

	/**
	 * 月交基数小于月交额度
	 *
	 * @param gjjData
	 * @return
	 */
	public static boolean baseLessDepositeBase(Object obj) {
		if (obj == null) {
			return false;
		}
		GjjData gjjData = new GjjData();
		if(obj instanceof GjjData){
			gjjData = (GjjData)obj;
		}else{
			return false;
		}
		try {
			BigDecimal base = new BigDecimal(gjjData.getBase());
			BigDecimal deposite_base = new BigDecimal(gjjData.getDeposite_base());
			return base.doubleValue() < deposite_base.doubleValue();
		} catch (Exception e) {
			log.error(e.toString(), e);
			return false;
		}
	}

	/**
	 * 余额等于公积金明细之和
	 *
	 * @param gjjData
	 * @return
	 */
	public static boolean balanceEqualsDetailBalanceSum(Object obj) {
		if (obj == null) {
			return false;
		}
		GjjData gjjData = new GjjData();
		if(obj instanceof GjjData){
			gjjData = (GjjData)obj;
		}else{
			return false;
		}
		try {
			BigDecimal balance = new BigDecimal(gjjData.getBalance());
			BigDecimal sumBalance = new BigDecimal("0");
			for (GjjDataDetail detail : gjjData.getDetails()) {
				sumBalance = sumBalance.add(new BigDecimal(detail.getTradeMoney()));
			}
			return balance.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() == sumBalance
					.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
		} catch (Exception e) {
			log.error(e.toString(), e);
			return false;
		}
	}

	/**
	 * 纯中文
	 *
	 * @param value
	 * @return
	 */
	public static boolean chinese(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		}
		char[] chars = value.toCharArray();
		boolean flag = false;
		for (char c : chars) {
			flag = CharUtils.IsChinese(c);
			if (!flag) {
				return flag;
			}
		}
		return true;
	}

	public static boolean numberOrLetter(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		}
		char[] chars = value.toCharArray();
		boolean flag = false;
		for (char c : chars) {
			flag = CharUtils.isLetter(c) || CharUtils.IsNum(c);
			if (!flag) {
				return flag;
			}
		}
		return true;
	}

	public static boolean numberAndLetter(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		}
		char[] chars = value.toCharArray();
		boolean flag = false;
		for (char c : chars) {
			flag = CharUtils.isLetter(c) || CharUtils.IsNum(c);
			if (!flag) {
				return flag;
			}
		}
		return true;
	}

	/**
	 * 检查是否含有中文
	 *
	 * @param value
	 * @return
	 */
	public static boolean containChinese(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		}
		char[] chars = value.toCharArray();
		boolean containChinese = false;
		for (char c : chars) {
			containChinese = CharUtils.IsChinese(c);
			if (containChinese) {
				return containChinese;
			}
		}
		return false;
	}

	public static boolean isEmail(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		}

		return emailPatten.matcher(value).matches();
	}

	/**
	 * 检查是否不含有中文
	 *
	 * @param value
	 * @return
	 */
	public static boolean notContainChinese(String value) {
		return !containChinese(value);
	}

	/**
	 * 是否整数
	 */
	public static boolean isInteger(String number) {
		return integerPatten.matcher(number).matches();
	}

	/**
	 * 含有空格
	 *
	 * @param value
	 * @return
	 */
	public static boolean containSpace(String value) {
		if (StringUtils.isEmpty(value))
			return false;
		return value.contains(" ");
	}

	/**
	 * 是否纯字母
	 *
	 * @param value
	 * @return
	 */

	public static boolean isLetter(String value) {
		if (StringUtils.isEmpty(value))
			return false;
		char[] chars = value.toCharArray();
		boolean isLetter = false;
		for (char c : chars) {
			isLetter = CharUtils.isLetter(c);
			if (isLetter) {
				return isLetter;
			}
		}
		return isLetter;
	}

	/***
	 * 长度
	 * 
	 * @param s
	 * @return
	 */
	public static int len(String s) {
		if (StringUtils.isEmpty(s))
			return 0;
		return s.length();
	}

	public static boolean isDate(String value) {
		if (StringUtils.isEmpty(value)) {
			return false;
		}
		Date date = DateUtils.get(value);
		if (date == null) {
			return false;
		}
		return true;
	}

	/**
	 * 时间是否大于1900-01-01
	 *
	 * @param date
	 * @return
	 */
	public static boolean isAfter1900Year(Date date) {
		if (date == null)
			return false;
		return date.after(beforeDate);
	}

	public static boolean isAfter1900Year(String dateStr) {
		Date date = DateUtils.get(dateStr);
		if (date == null)
			return false;
		return date.after(beforeDate);
	}

	public static boolean isBefereNow(Date date) {
		if (date == null)
			return false;
		return date.before(new Date());
	}

	public static boolean isBefereNow(String dateStr) {
		Date date = DateUtils.get(dateStr);
		if (date == null)
			return false;
		return date.before(new Date());
	}

	public static boolean isNumber(String number) {
		return isInteger(number) || isDecimal(number);
	}

	/**
	 * 正数
	 *
	 * @param number
	 * @return
	 */
	public static boolean isPositiveNumber(String number) {
		return (isInteger(number) || isDecimal(number)) && !number.startsWith("-");
	}

	/***
	 * 负数
	 * 
	 * @param number
	 * @return
	 */
	public static boolean isNegativeNumber(String number) {
		if (StringUtils.isEmpty(number)) {
			return false;
		}
		return (isInteger(number) || isDecimal(number)) && number.startsWith("-");
	}

	// 小数
	public static boolean isDecimal(String number) {
		if (StringUtils.isEmpty(number)) {
			return false;
		}
		return floatPatten.matcher(number).matches();
	}

}
